﻿
package system.data;

import java.util.*;

import framework.core.*;
/*
	Author    :justin
	CreateTime:2008-01-03 16:28:33
*/
public class UserBase extends Table 
{
public static final String TABLE_NAME = "T_USER";

private static final String BACKUP_TABLE_NAME = "T_USER_BACKUP";

private static final String BACKUP_SEQ_NAME = "S_USER_BACKUP";


public static final String ID = "ID";

public static final String CODE = "CODE";

public static final String PASSWORD = "PASSWORD";

public static final String WAREHOUSE_CODE = "WAREHOUSE_CODE";

public static final String WAREHOUSE_NAME = "WAREHOUSE_NAME";

public static final String NAME = "NAME";

public static final String TEL = "TEL";

public static final String MOBILE_PHONE = "MOBILE_PHONE";

public static final String REMARK = "REMARK";

public static final String STATUS = "STATUS";


public static Vector m_fields = null;


private String m_id = ""; //序号

private String m_code = ""; //用户名

private String m_password = ""; //密码

private String m_warehouse_code = ""; //仓库编码

private String m_warehouse_name = ""; //仓库名称

private String m_name = ""; //姓名

private String m_tel = ""; //联系电话

private String m_mobile_phone = ""; //移动电话

private String m_remark = ""; //备注

private String m_status = ""; //是否有效



	public String getId()
	{
	    return m_id;
	}
	public void  setId(String v)
	{
		if(getId().equals(v)) return ;
		m_id = v ;
		markDirty(ID);
	}



	

	public String getCode()
	{
	    return m_code;
	}
	public void  setCode(String v)
	{
		if(getCode().equals(v)) return ;
		m_code = v ;
		markDirty(CODE);
	}



	

	public String getPassword()
	{
	    return m_password;
	}
	public void  setPassword(String v)
	{
		if(getPassword().equals(v)) return ;
		m_password = v ;
		markDirty(PASSWORD);
	}



	

	public String getWarehouseCode()
	{
	    return m_warehouse_code;
	}
	public void  setWarehouseCode(String v)
	{
		if(getWarehouseCode().equals(v)) return ;
		m_warehouse_code = v ;
		markDirty(WAREHOUSE_CODE);
	}



	

	public String getWarehouseName()
	{
	    return m_warehouse_name;
	}
	public void  setWarehouseName(String v)
	{
		if(getWarehouseName().equals(v)) return ;
		m_warehouse_name = v ;
		markDirty(WAREHOUSE_NAME);
	}



	

	public String getName()
	{
	    return m_name;
	}
	public void  setName(String v)
	{
		if(getName().equals(v)) return ;
		m_name = v ;
		markDirty(NAME);
	}



	

	public String getTel()
	{
	    return m_tel;
	}
	public void  setTel(String v)
	{
		if(getTel().equals(v)) return ;
		m_tel = v ;
		markDirty(TEL);
	}



	

	public String getMobilePhone()
	{
	    return m_mobile_phone;
	}
	public void  setMobilePhone(String v)
	{
		if(getMobilePhone().equals(v)) return ;
		m_mobile_phone = v ;
		markDirty(MOBILE_PHONE);
	}



	

	public String getRemark()
	{
	    return m_remark;
	}
	public void  setRemark(String v)
	{
		if(getRemark().equals(v)) return ;
		m_remark = v ;
		markDirty(REMARK);
	}



	

	public String getStatus()
	{
	    return m_status;
	}
	public void  setStatus(String v)
	{
		if(getStatus().equals(v)) return ;
		m_status = v ;
		markDirty(STATUS);
	}



	



	public String viewId(DBConnection con) throws Exception
	{
		return Value.view(getId());
	}

	public String viewCode(DBConnection con) throws Exception
	{
		return Value.view(getCode());
	}

	public String viewPassword(DBConnection con) throws Exception
	{
		return Value.view(getPassword());
	}

	public String viewWarehouseCode(DBConnection con) throws Exception
	{
		return Value.view(getWarehouseCode());
	}

	public String viewWarehouseName(DBConnection con) throws Exception
	{
		return Value.view(getWarehouseName());
	}

	public String viewName(DBConnection con) throws Exception
	{
		return Value.view(getName());
	}

	public String viewTel(DBConnection con) throws Exception
	{
		return Value.view(getTel());
	}

	public String viewMobilePhone(DBConnection con) throws Exception
	{
		return Value.view(getMobilePhone());
	}

	public String viewRemark(DBConnection con) throws Exception
	{
		return Value.view(getRemark());
	}

	public String viewStatus(DBConnection con) throws Exception
	{
		return Value.view(getStatus());
	}



protected UserBase()
{
}

public void fill(UserPageData pageData) throws Exception
{

	if(pageData.getId()!=null)
	{	
		setId(pageData.getId());
	}

	if(pageData.getCode()!=null)
	{	
		setCode(pageData.getCode());
	}

	if(pageData.getPassword()!=null)
	{	
		setPassword(pageData.getPassword());
	}

	if(pageData.getWarehouseCode()!=null)
	{	
		setWarehouseCode(pageData.getWarehouseCode());
	}

	if(pageData.getWarehouseName()!=null)
	{	
		setWarehouseName(pageData.getWarehouseName());
	}

	if(pageData.getName()!=null)
	{	
		setName(pageData.getName());
	}

	if(pageData.getTel()!=null)
	{	
		setTel(pageData.getTel());
	}

	if(pageData.getMobilePhone()!=null)
	{	
		setMobilePhone(pageData.getMobilePhone());
	}

	if(pageData.getRemark()!=null)
	{	
		setRemark(pageData.getRemark());
	}

	if(pageData.getStatus()!=null)
	{	
		setStatus(pageData.getStatus());
	}

}

public String getTableName() 
{
	return TABLE_NAME;
}

public String getBackupTableName() 
{
	return BACKUP_TABLE_NAME;
}

public String getBackupSeqName() 
{
	return BACKUP_SEQ_NAME;
}

public java.util.Vector getFields() 
{
	if(m_fields==null)
	{
		m_fields = new Vector();

		m_fields.add(new Field(ID,Value.TYPE_STRING,true,true,32,"序号"));

		m_fields.add(new Field(CODE,Value.TYPE_STRING,false,true,50,"用户名"));

		m_fields.add(new Field(PASSWORD,Value.TYPE_STRING,false,true,20,"密码"));

		m_fields.add(new Field(WAREHOUSE_CODE,Value.TYPE_STRING,false,true,20,"仓库编码"));

		m_fields.add(new Field(WAREHOUSE_NAME,Value.TYPE_STRING,false,true,50,"仓库名称"));

		m_fields.add(new Field(NAME,Value.TYPE_STRING,false,true,20,"姓名"));

		m_fields.add(new Field(TEL,Value.TYPE_STRING,false,false,50,"联系电话"));

		m_fields.add(new Field(MOBILE_PHONE,Value.TYPE_STRING,false,false,50,"移动电话"));

		m_fields.add(new Field(REMARK,Value.TYPE_STRING,false,false,500,"备注"));

		m_fields.add(new Field(STATUS,Value.TYPE_STRING,false,true,1,"是否有效"));
		
	}
	return m_fields;
}

public void initObject(java.sql.ResultSet rs) throws Exception
{

	m_id = getString(rs,ID);

	m_code = getString(rs,CODE);

	m_password = getString(rs,PASSWORD);

	m_warehouse_code = getString(rs,WAREHOUSE_CODE);

	m_warehouse_name = getString(rs,WAREHOUSE_NAME);

	m_name = getString(rs,NAME);

	m_tel = getString(rs,TEL);

	m_mobile_phone = getString(rs,MOBILE_PHONE);

	m_remark = getString(rs,REMARK);

	m_status = getString(rs,STATUS);

	ms_new_flag = ConstDefine.NO;
}

public Value get(String f)
{

	if(f.equalsIgnoreCase(ID))
	{
		return new Value(getId());
	}

	if(f.equalsIgnoreCase(CODE))
	{
		return new Value(getCode());
	}

	if(f.equalsIgnoreCase(PASSWORD))
	{
		return new Value(getPassword());
	}

	if(f.equalsIgnoreCase(WAREHOUSE_CODE))
	{
		return new Value(getWarehouseCode());
	}

	if(f.equalsIgnoreCase(WAREHOUSE_NAME))
	{
		return new Value(getWarehouseName());
	}

	if(f.equalsIgnoreCase(NAME))
	{
		return new Value(getName());
	}

	if(f.equalsIgnoreCase(TEL))
	{
		return new Value(getTel());
	}

	if(f.equalsIgnoreCase(MOBILE_PHONE))
	{
		return new Value(getMobilePhone());
	}

	if(f.equalsIgnoreCase(REMARK))
	{
		return new Value(getRemark());
	}

	if(f.equalsIgnoreCase(STATUS))
	{
		return new Value(getStatus());
	}
	
	return null;
}
public void set(String f,Value v) throws Exception
{

	if(f.equalsIgnoreCase(ID))
	{
		setId(v.getString());
	}

	if(f.equalsIgnoreCase(CODE))
	{
		setCode(v.getString());
	}

	if(f.equalsIgnoreCase(PASSWORD))
	{
		setPassword(v.getString());
	}

	if(f.equalsIgnoreCase(WAREHOUSE_CODE))
	{
		setWarehouseCode(v.getString());
	}

	if(f.equalsIgnoreCase(WAREHOUSE_NAME))
	{
		setWarehouseName(v.getString());
	}

	if(f.equalsIgnoreCase(NAME))
	{
		setName(v.getString());
	}

	if(f.equalsIgnoreCase(TEL))
	{
		setTel(v.getString());
	}

	if(f.equalsIgnoreCase(MOBILE_PHONE))
	{
		setMobilePhone(v.getString());
	}

	if(f.equalsIgnoreCase(REMARK))
	{
		setRemark(v.getString());
	}

	if(f.equalsIgnoreCase(STATUS))
	{
		setStatus(v.getString());
	}
	
}
public String toString()
{
	String msg = "User=\n";
	msg += "(\r\n";

	msg += "    序号(id)="+get("id")+"\r\n";

	msg += "    用户名(code)="+get("code")+"\r\n";

	msg += "    密码(password)="+get("password")+"\r\n";

	msg += "    仓库编码(warehouse_code)="+get("warehouse_code")+"\r\n";

	msg += "    仓库名称(warehouse_name)="+get("warehouse_name")+"\r\n";

	msg += "    姓名(name)="+get("name")+"\r\n";

	msg += "    联系电话(tel)="+get("tel")+"\r\n";

	msg += "    移动电话(mobile_phone)="+get("mobile_phone")+"\r\n";

	msg += "    备注(remark)="+get("remark")+"\r\n";

	msg += "    是否有效(status)="+get("status")+"\r\n";
		
	msg += ")\r\n";
	return msg;
}
public void copyBase(UserBase srcObj)
{

	setId(srcObj.getId());

	setPassword(srcObj.getPassword());

	setWarehouseCode(srcObj.getWarehouseCode());

	setWarehouseName(srcObj.getWarehouseName());

	setName(srcObj.getName());

	setTel(srcObj.getTel());

	setMobilePhone(srcObj.getMobilePhone());

	setRemark(srcObj.getRemark());

	setStatus(srcObj.getStatus());

}

public String toXml() throws Exception
{
	String xml = "";
	xml += "<User>";

	xml += "<Id>"+Value.view(getId())+"</Id>";

	xml += "<Code>"+Value.view(getCode())+"</Code>";

	xml += "<Password>"+Value.view(getPassword())+"</Password>";

	xml += "<WarehouseCode>"+Value.view(getWarehouseCode())+"</WarehouseCode>";

	xml += "<WarehouseName>"+Value.view(getWarehouseName())+"</WarehouseName>";

	xml += "<Name>"+Value.view(getName())+"</Name>";

	xml += "<Tel>"+Value.view(getTel())+"</Tel>";

	xml += "<MobilePhone>"+Value.view(getMobilePhone())+"</MobilePhone>";

	xml += "<Remark>"+Value.view(getRemark())+"</Remark>";

	xml += "<Status>"+Value.view(getStatus())+"</Status>";
	
	xml += "</User>";
	return xml;
}

}
